package func;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

import org.junit.Test;

/*
public interface Predicate<T> {
	boolean test(T t);
}
 */
public class PredicateDemo {
	@Test
	public void test1() {
		Predicate<String> p = new Predicate<String>() {
			@Override
			public boolean test(String t) {
				return t.contains("a");
			}
		};
		System.out.println(p.test("lajfsa"));
	}
	
	@Test
	public void test2() {
		Predicate<String> p = t -> t.startsWith("a");
		System.out.println(p.test("bdeaf"));
	}
	
	@Test
	public void test3() {
		//filter
		List<String> list = Arrays.asList("qwrafa","safkjowie","safksaw","afsafaf","o2r2waf");
		list.stream().filter(t -> t.contains("j")).forEach(t -> System.out.println(t));
	}
}
